<?php
class Admin_Form_TinTucForm extends Zend_Form{
	public function __construct($option = null){
		parent::__construct($option);
		
		$this->setName('tintuc');
		
		
		$machude = new Zend_Form_Element_Select('machude');
		$machude->setLabel('Tên chủ đề: ')
						->setRequired(true);
		
		$chudeMapper = Library_Model_ChuDeMapper::getInstance();
		$chudes = $chudeMapper->chudeList();
		foreach($chudes as $chude)
		{
			$machude->addMultiOptions(array(
					$chude->getId() => $chude->getTenchude()
			));
		} 
		
		$mand = new Zend_Form_Element_Select('mand');
		$mand->setLabel('Tên người dùng:  ')
						->setRequired(true);
		
		$nguoidungMapper = Library_Model_NguoiDungMapper::getInstance();
		$nguoidungs = $nguoidungMapper->nguoidungList();
		foreach($nguoidungs as $nguoidung)
		{
			$mand->addMultiOptions(array(
					$nguoidung->getId() => $nguoidung->getTennd()
			));
		} ;
		
		$tenbaiviet = new Zend_Form_Element_Text('tenbaiviet');
		$tenbaiviet->setLabel('Tên bài viết: ')
							->setRequired(true);
		
		$tomtat = new Zend_Form_Element_Textarea('tomtat');
		$tomtat->setLabel('Tóm tắt : ')
									->setRequired(true)
									->setAttribs(array(
														'cols' => '60',
														'rows' => '10'));
		
		$noidung = new Zend_Form_Element_Textarea('noidung');
		$noidung->setLabel('Nội dung: ')
								->setRequired(true)
								->setAttribs(array(
														'cols' => '60',
														'rows' => '20'));
						
		$luotxem = new Zend_Form_Element_Text('$luotxem');
		$luotxem->setLabel('Lượt xem :')
			   ->setRequired(true)
			   ->addValidator('Int');
		
		$kiemduyet = new Zend_Form_Element_Radio('kiemduyet');
		$kiemduyet->setLabel('Trạng thái: ')
		->setRequired(true);
		$kiemduyet->setMultiOptions(array(
				'1' => 'Mở',
				'0' => 'Không'));
		
		
		
		$this->addElements(array($machude,  $tenbaiviet, $noidung,  $tomtat, $luotxem, $kiemduyet ,$mand));

	}
}